package com.zqh.categoryquery.config;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;

/**
 * @Description : mp自动填充实现
 * @Author :kono淇杭哒、
 * @Create 2021-09-11 18:30
 */
@Component
public class MyMetaObjectHandler implements MetaObjectHandler{
    @Override
    public void insertFill(MetaObject metaObject) {
        this.setFieldValByName("createTime", LocalDateTime.now(),metaObject);
        this.setFieldValByName("userRegtime", LocalDateTime.now(),metaObject);
        this.setFieldValByName("updateTime",LocalDateTime.now(),metaObject);
        this.setFieldValByName("userModtime",LocalDateTime.now(),metaObject);
        this.setFieldValByName("userImg","https://tse2-mm.cn.bing.net/th/id/OIP-C.7mLIU1xTEl4suDSmrw_-kgHaHY?w=211&h=210&c=7&r=0&o=5&pid=1.7",metaObject);
    }

    @Override
    public void updateFill(MetaObject metaObject) {
        this.setFieldValByName("updateTime",LocalDateTime.now(),metaObject);
        this.setFieldValByName("userModtime",LocalDateTime.now(),metaObject);
    }



}
